﻿using log4net;
using Quartz;
using quartz_service.Entities;
using quartz_service.Tools;

namespace quartz_service.JobTasks
{
    public class AddJob : IJob
    {
        private static readonly ILog logger = LogManager.GetLogger(typeof(AddJob));

        public async Task Execute(IJobExecutionContext context)
        {
            await Task.Run(async () =>
            {
                try
                {
                    int id = await SqlSugarHelper.Db
                        .Insertable(new Add_Log { Add_Time = DateTime.Now })
                        .ExecuteReturnIdentityAsync();

                    logger.Info($"添加数据成功, 主键为: " + id);
                }
                catch (Exception ex)
                {
                    logger.Error("添加数据失败, 异常为: " + ex.ToString());
                }
            });
        }
    }
}
